Package com.eforce.comp1

Source Code of com.eforce.comp1.InputExample

package com.eforce.comp1;

/**
* This file contains all the constants that will be used in the application.
* @author ABiswas
*
*/

import java.io.*;
import java.util.Scanner;
//import java.io.*;
import java.io.File;
import java.io.PrintWriter;

public class InputExample {
public static void main(String args[ ]) throws IOException {
Scanner s = new Scanner(System.in);
System.out.print("Enter your height in centimeters: ");
float height = s.nextFloat();
System.out.print("Enter your weight in kilograms: ");
float weight = s.nextFloat();
float bmi = weight/(height*height)*10000;
System.out.println("Your body mass index is " + bmi + ".");

System.out.printf("%8.2f", bmi);
String name = "Anish";
int age = 12;

System.out.printf("Hello, %s. Next year, you'll be %d", name, age);

//Scanner in = new Scanner(new File("myfile.txt"));

/*
Scanner in = new Scanner(System.in);
while (sum < goal)
{
System.out.print("Enter a number: ");
n = in.nextInt();
if (n < 0) continue;
sum += n; // not executed if n < 0
}
*/

}
}
TOP

Related Classes of com.eforce.comp1.InputExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.